package com.qiujie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qiujie.entity.ApproveFlow;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

public interface ApproveFlowMapper extends BaseMapper<ApproveFlow> {

    /**
     * 根据流程类型获取审批流程节点
     */
    @Select("SELECT * FROM att_approve_flow " +
            "WHERE flow_key = #{flowKey} " +
            "ORDER BY node_order ASC")
    List<ApproveFlow> getByFlowKey(@Param("flowKey") String flowKey);

    /**
     * 根据流程类型和节点顺序查询节点配置
     */
    @Select("SELECT * FROM att_approve_flow " +
            "WHERE flow_key = #{flowKey} AND node_order = #{nodeOrder}")
    ApproveFlow getByFlowAndNode(@Param("flowKey") String flowKey,
                                 @Param("nodeOrder") Integer nodeOrder);


    @Select("SELECT level FROM per_role_level WHERE role_code = #{roleCode}")
    String getRoleLevelByCode(@Param("roleCode") String roleCode);
}
